package com.tang.mapper;

import com.tang.entity.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author TangBowen
 * @create 2021/6/7 14:43
 */
public interface StudentMapper {
    /**
     *查询所有学生
     * @return 学生列表
     */
    @Select("SELECT * FROM student")
    List<Student> selectAll();

    /**
     * 添加学生方法
     *
     */
    @Insert("INSERT INTO student VALUES (#{number},#{name},#{birthday},#{address})")
    void addStu(Student stu);

    /**
     * 修改学生方法
     * @param stu
     */
    @Update("UPDATE student SET number=#{number},name=#{name},birthday=#{birthday},address=#{address} WHERE number=#{number}")
    void updateStu(Student stu);

    @Delete("DELETE FROM student WHERE number=#{number}")
    void deleteStu(String number);
}
